package red.action;

import com.opensymphony.xwork2.Action;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import red.mapper.Columnmapper;
import red.model.ColumnModel;
import red.service.ColumnService;
import red.service.impl.ColumnServiceImpl;
import red.util.BaseAction;
import red.util.Model;
import red.util.SqlSessionFactoryUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@SuppressWarnings("ALL")
public class ColumnAction extends BaseAction {

    private Map<String,Object> result;

    @Autowired
    private ColumnServiceImpl columnService;

    private ColumnModel columnModel;

    private List<ColumnModel> columnModels;

    List list=new ArrayList<>();

    public ColumnModel getColumnModel() {
        return columnModel;
    }

    public void setColumnModel(ColumnModel columnModel) {
        this.columnModel = columnModel;
    }

    public List<ColumnModel> getColumnModels() {
        return columnModels;
    }

    public void setColumnModels(List<ColumnModel> columnModels) {
        this.columnModels = columnModels;
    }
    public Map<String, Object> getResult() {
        return result;
    }
    public void setResult(Map<String, Object> result) {
        this.result = result;
    }

    public  String selectcol() throws IOException {
        Model model = getParams();
        columnModels=columnService.selectCol(model);
        result.put("data",columnModels);
        return Action.SUCCESS;
    }
    public String deletecol() throws IOException {
        Model model = getParams();
        columnModel=columnService.deleteCol(model);
        return Action.SUCCESS;
    }
    public String addcol() throws IOException {
        Model model = getParams();
        columnModel=columnService.addCol(model);
        return Action.SUCCESS;
    }

}
